home *** CD-ROM | disk | FTP | other *** search
-
- #include "handler.h"
-
-
- void directiveHandler(String ts,String as,String et,Dictionary td)
- {
- String argString = 0;
- String endTag = 0;
- String type;
- void (*handler)();
-
- type = dict_valueForKey(td,"TYPE");
-
- if(type->string)
- {
- String registeredType;
-
- registeredType = string_alloc(strlen(type->string));
-
- string_setStringValue(registeredType , "directive.");
- string_appendString(registeredType , type->string);
-
- /* See if there is an endtag or a handler registered*/
- endTag = dict_valueForKey(endTags, registeredType->string);
-
- handler = dict_valueForKey(handlerDict, registeredType->string);
-
- string_free(registeredType);
- }
-
- /* If there is a handler, use it */
- if(handler)
- {
- /* If there is an end tag, parse up to it
- * be sure to remove the end tag from the body text.
- */
- if(endTag && endTag->string)
- {
- char * finalPointy = 0;
-
- argString = mainHtmlParser(endTag->string);
-
- /* Get rid of the end tag */
-
- if(endTag->string[0] == '<')/* this is a real tag */
- {
- finalPointy = strrchr(argString->string,'<');
-
- /* End the string at the final <, thus removing the end tag */
- if(finalPointy) *finalPointy = '\0';
- }
- }
-
- /* Call the handler */
- handler(ts,argString,endTag,td);
- }
- else /* No handler, treat this as plain text */
- {
- string_setStringValue(ts,"");
- }
-
- /* Clean up */
- string_free(argString);
- }
-
- void webmasterHandler(String ts,String as,String et,Dictionary td)
- {
- /* Set the tag string to the link that we want inserted */
- string_setStringValue(ts,"<A HREF=\"mailto:joe@webmastersrus.com\">joe@webmastersrus.com</A>");
- }
-